package com.xyzq.model.sm;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.appfuse.model.BaseObject;
import org.appfuse.model.User;

@Entity
@Table(name = "order_client")
public class OrderClient extends BaseObject implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -8453425402530145239L;
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private Long id;
	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "FK_USER_USER", nullable = false)
	private User user;
	private String client;
	@Column(name = "id_card")
	private String idCard;
	@Column(name = "order_type")
	private String orderType;
	@Column(name = "source")
	private String source;
	private String introducer;
	@Column(name = "introducer_cell")
	private String introducerCell;
	private String remark;
	@Temporal(TemporalType.DATE)
	@Column(name = "order_date")
	private Date orderDate;
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "sub_time")
	private Date subTime;
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "modify_time")
	private Date modifyTime;
	private boolean subSystem;

	public Long getId() {
		return id;
	}

	public String getClient() {
		return client;
	}

	public String getOrderType() {
		return orderType;
	}

	public String getSource() {
		return source;
	}

	public String getIntroducer() {
		return introducer;
	}

	public String getIntroducerCell() {
		return introducerCell;
	}

	public Date getOrderDate() {
		return orderDate;
	}

	public Date getSubTime() {
		return subTime;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public void setClient(String client) {
		this.client = client;
	}

	public void setOrderType(String orderType) {
		this.orderType = orderType;
	}

	public void setSource(String source) {
		this.source = source;
	}

	public void setIntroducer(String introducer) {
		this.introducer = introducer;
	}

	public void setIntroducerCell(String introducerCell) {
		this.introducerCell = introducerCell;
	}

	public void setOrderDate(Date orderDate) {
		this.orderDate = orderDate;
	}

	public void setSubTime(Date subTime) {
		this.subTime = subTime;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((client == null) ? 0 : client.hashCode());
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result + ((idCard == null) ? 0 : idCard.hashCode());
		result = prime * result
				+ ((introducer == null) ? 0 : introducer.hashCode());
		result = prime * result
				+ ((introducerCell == null) ? 0 : introducerCell.hashCode());
		result = prime * result
				+ ((modifyTime == null) ? 0 : modifyTime.hashCode());
		result = prime * result
				+ ((orderDate == null) ? 0 : orderDate.hashCode());
		result = prime * result
				+ ((orderType == null) ? 0 : orderType.hashCode());
		result = prime * result + ((remark == null) ? 0 : remark.hashCode());
		result = prime * result + ((source == null) ? 0 : source.hashCode());
		result = prime * result + (subSystem ? 1231 : 1237);
		result = prime * result + ((subTime == null) ? 0 : subTime.hashCode());
		result = prime * result + ((user == null) ? 0 : user.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		OrderClient other = (OrderClient) obj;
		if (client == null) {
			if (other.client != null)
				return false;
		} else if (!client.equals(other.client))
			return false;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		if (idCard == null) {
			if (other.idCard != null)
				return false;
		} else if (!idCard.equals(other.idCard))
			return false;
		if (introducer == null) {
			if (other.introducer != null)
				return false;
		} else if (!introducer.equals(other.introducer))
			return false;
		if (introducerCell == null) {
			if (other.introducerCell != null)
				return false;
		} else if (!introducerCell.equals(other.introducerCell))
			return false;
		if (modifyTime == null) {
			if (other.modifyTime != null)
				return false;
		} else if (!modifyTime.equals(other.modifyTime))
			return false;
		if (orderDate == null) {
			if (other.orderDate != null)
				return false;
		} else if (!orderDate.equals(other.orderDate))
			return false;
		if (orderType == null) {
			if (other.orderType != null)
				return false;
		} else if (!orderType.equals(other.orderType))
			return false;
		if (remark == null) {
			if (other.remark != null)
				return false;
		} else if (!remark.equals(other.remark))
			return false;
		if (source == null) {
			if (other.source != null)
				return false;
		} else if (!source.equals(other.source))
			return false;
		if (subSystem != other.subSystem)
			return false;
		if (subTime == null) {
			if (other.subTime != null)
				return false;
		} else if (!subTime.equals(other.subTime))
			return false;
		if (user == null) {
			if (other.user != null)
				return false;
		} else if (!user.equals(other.user))
			return false;
		return true;
	}

	@Override
	public String toString() {
		ToStringBuilder builder = new ToStringBuilder(this,
				ToStringStyle.DEFAULT_STYLE);
		builder.append("id", id);
		builder.append("user", user);
		builder.append("client", client);
		builder.append("idCard", idCard);
		builder.append("orderType", orderType);
		builder.append("source", source);
		builder.append("introducer", introducer);
		builder.append("introducerCell", introducerCell);
		builder.append("remark", remark);
		builder.append("orderDate", orderDate);
		builder.append("subTime", subTime);
		builder.append("modifyTime", modifyTime);
		builder.append("subSystem",subSystem);
		return builder.toString();
	}

	public void setUser(User user) {
		this.user = user;
	}

	public User getUser() {
		return user;
	}

	public void setModifyTime(Date modifyTime) {
		this.modifyTime = modifyTime;
	}

	public Date getModifyTime() {
		return modifyTime;
	}

	public void setIdCard(String idCard) {
		this.idCard = idCard;
	}

	public String getIdCard() {
		return idCard;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public String getRemark() {
		return remark;
	}

	public boolean isSubSystem() {
		return subSystem;
	}

	public void setSubSystem(boolean subSystem) {
		this.subSystem = subSystem;
	}

}
